package com.blue.core.dict;

import com.blue.core.dict.annotation.Dict;

/**
 * 微信请求报文类型
 * 
 * @author zhengj
 * @since 1.0 2017年1月14日
 */
@Dict
public enum WechatRequestType
{
	TEXT(1, "文本", Color.BLUE),
	IMAGE(2, "图片", Color.NAVY),
	VOICE(3, "声音", Color.RED),
	VIDEO(4, "视频", Color.MAROON),
	LOCATION(5, "位置", Color.GRAY), 
	LINK(6, "链接", Color.FUCHSIA),
	EVENT(7, "事件", Color.BLACK),
	SHORT_VIDEO(8, "小视频", Color.YELLOW);
	
	private Integer index;
	private String name;
	private Color color;
	
	WechatRequestType(Integer index, String name, Color color)
	{
		this.index = index;
		this.name = name;
		this.color = color;
	}

	public Integer getIndex()
	{
		return index;
	}

	public String getName()
	{
		return name;
	}

	public Color getColor()
	{
		return color;
	}
	
	public static WechatRequestType getType(String type)
	{
		if (type == null || type.equals(""))
			return null;

		type = type.toUpperCase();
		return WechatRequestType.valueOf(type);
	}

	public static WechatRequestType getIndex(int index)
	{
		for (WechatRequestType t : WechatRequestType.values())
		{
			if (t.getIndex() == index)
				return t;
		}
		return null;
	}
	
	public String getText()
	{
		return this.name().toLowerCase();
	}

	@Override
	public String toString()
	{
		return String.format("<span style=\"color: %s;\">%s</span>", color.name().toLowerCase(), name);
	}

}
